package morenoapp.components.common;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JTextField;
import javax.swing.text.Document;

/**
 *
 * @author root
 */
public class HintTextField extends JTextField {
    String hint = "Use setHint to change this value"; //NOI18N
    public HintTextField(Document doc, String text, int columns) {
        super(doc, text, columns);
    }

    public HintTextField(String text, int columns) {
        super(text, columns);
    }

    public HintTextField(int columns) {
        super(columns);
    }

    public HintTextField(String text) {
        super(text);
    }

    public HintTextField() {
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (getDocument().getLength() == 0 && isFocusOwner()==false) {
            int baseline = getBaseline(getWidth(), getHeight());
            g.setColor(Color.LIGHT_GRAY);
            g.drawString(hint, getInsets().left, baseline);
        }
    }
}
